<script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery('#CloseupComment').live("keyup blur", function(){
            if (jQuery('#CloseupComment').val().length > 0) {
                jQuery('#PostComment').removeClass('disabled');
            }
            else {
                jQuery('#PostComment').addClass('disabled');
            }
        });
		
        var k = jQuery('#PostComment'), j = jQuery('#CloseupComment'), h = jQuery(".PinComments"), u = jQuery("#user_id")
        k.click(function(){
            if (k.attr("disabled") == "disabled") 
                return false;
            jQuery.post("/pin/add_comment/", {
                text: j.val(),
				pin_id: '<%= params[:id]%>',
				user_id: u.val()
            }, function(r){
                if (r && r.status == "success") {
					src = "<div class='comment' id='" + "comment_" + r.id + "'>";
					//src += r.remote;
					src += "<a href='#' title='删除' class='DeleteComment floatRight tipsyHover' onclick=\"new Ajax.Request('/pin/del_comment/" + r.id + "', {asynchronous:true, evalScripts:true}); return false;\">";
					src += "<span style='font-size:16px'>×</span>";
					src += "</a>";
					src += "<a class='CommenterImage' href='/user/item/" + r.user_id + "'>";
					src += "<img src='" + r.image + "' alt='" + r.alt + "'/>";
					src += "</a>";
					src += "<p class='CommenterMeta'>";
					src += "<a class='CommenterName' href='#'>" + r.name + "</a>"
					src += "<br />";
					src += r.text;
					src += "</p>";
					src += "</div>"
                    h.append(src);
                    j.val("").blur();
                    k.addClass("disabled");
                }
                else {
                    //l.html(r.message).css("color", "red").show();
                    //k.removeClass("disabled").removeAttr("disabled")
                }
            }, "json");
            return false
        })
    });
</script>
<div class="FixedContainer">
	<div class="CloseupLeft">
		<div id="SocialShare">
			<ul>
				<li></li>
				<li></li>
				<li><a id="PinReport" class="Button WhiteButton Button11" href="#">⚐ 举报</a></li>
				<li></li>
			</ul>
		</div>
		<div class="pin pinBoard">
			<h3><%= link_to @board.name, {:controller => :board, :action => :item, :id => @board.id}%></h3>
			<h4><%= @board.pins.count%>个采集</h4>
			<div class="Board">
				<!--
				<a class="link" href='#'></a>
                <div class="holder">
                    <span class="cover">
                    	<img onerror="this.src = this.src.replace('_222.jpg', '_b.jpg'); this.onerror = null; return false;" onload="this.style.opacity=1" style="opacity: 1;" width="222px" height="150px" src="http://media-cache-lt0.pinterest.com/upload/337066353330497574_Fj8hMi1f_222.jpg">
					</span>
					<span class="thumbs">
						<img onload="this.style.opacity=1" style="opacity: 1;" alt="Photo of a pin" src="http://media-cache-ec6.pinterest.com/upload/337066353330497564_Pd32Ptxl_t.jpg">
						<span class="empty"></span>
						<span class="empty"></span>
						<span class="empty"></span>
					</span>
                </div>
				-->
				<% if logged_in? && @board.user_id == current_user.id%>
				<div class="followBoard">
					<%= link_to "编辑画板", {:controller => :board, :action => :edit, :id => @board.id}, :class => "Button13 Button WhiteButton InlineButton"%>
				</div>
				<% end%>
			</div>
		</div>
		<!--
		<div class="pin whiteContainer domainPins clearfix">
			<h3>同采自<a class="colorless" href="/source/weibo.com">weibo.com</a></h3>
			<a class="link" href="/source/weibo.com">
				<img src="http://media-cache-ec3.pinterest.com/upload/168181367305691204_0QgIcQvE_t.jpg">
				<img src="http://media-cache-ec6.pinterest.com/upload/337066353330497564_Pd32Ptxl_t.jpg">
				<img src="http://media-cache-ec4.pinterest.com/upload/14988611230774213_yLAXGe6Q_t.jpg">
			</a>
		</div>
		-->
	</div>
	<div class="CloseupRight">
		<div class="WhiteContainer clearfix">
	        <div id="PinPinner">
	            <a id="PinnerImage" class="ImgLink" href="/winseed/">
	            	<img alt="User Profile Picture" src="/images/avatar/noAvatar.jpg">
				</a>
	            <p id="PinnerName">
	                <a href="/user/"><%= @pin.user.name%></a>
	            </p>
	            <p id="PinnerStats" class="colorless">采集于<%= date_time_format_l(@pin.created_at)%></p>
	        </div>
			<div id="PinActionButtons">
				<p id="PinSource" class="colorlight">来自<%= link_to @pin.from, @pin.url, :popup => true%></p>
				<ul>
					<!--
					<li>
						<%#= link_to "转发", {:controller => :pin, :action => :repin, :id => @pin.id}, :class => "button button13 whiteButton"%>
					</li>
					-->
					<% if @user.try(:id) == @pin.try(:board).try(:user_id)%>
					<li>
						<%= link_to "编辑", {:controller => :pin, :action => :edit, :id => @pin.id}, :class => "Button Button13 WhiteButton"%>
					</li>
					<% else%>
					<li class="like-button">
						<%= link_to_remote "<em></em>喜欢",
							:url => {:controller => :pin, :action => :like, :id => @pin.id}, 
							:html => {:title => "喜欢", :data_id => @pin.id, :class => "Button Button13 WhiteButton"} 
						%>
					</li>
					<% end%>
				</ul>
			</div>
			<div id="PinImageHolder" class="ImgLink">
				<a href="<%= @pin.url%>" target="_blank">
					<img id="PinCloseupImage" src="<%= @pin.media%>">
				</a>
			</div>
			<div id="PinCaption">
				<%= @pin.description%>                              
				<p id="PinOrigin" class="colorlight">
					通过
					<a class="colorless" href="/about/goodies/">书签工具栏</a>
				</p>
			</div>
			<a id="comments" name="comments"></a>
			<div class="PinComments">
				<!--
				<div class="comment">
					<a href="#" title="删除" class="deleteComment floatRight tipsyHover">
						<span style="font-size:16px">×</span>
					</a>
					<a href="#" class="commenterImage">
						<img alt="李 景龙" src="http://media-cache-ec6.pinterest.com/avatars/winseed-1345193545.jpg">
					</a>
					<p class="commenterMeta">
						<a href="#" class="commenterName">李 景龙</a>
						<br />
						O(∩_∩)O~
					</p>
				</div>
				-->
				<% @comments.each do |comment|%>
				<div class="comment" id="comment_<%= comment.id%>">
					<!--
					<a href="#" title="删除" class="deleteComment floatRight tipsyHover">
						<span style="font-size:16px">×</span>
					</a>
					-->
					<% if logged_in? && @user.try(:id) == comment.user_id%>
					<%= link_to_remote "<span style='font-size:16px'>×</span>", 
						:url => {:controller => :pin, :action => :del_comment, :id => comment.id}, 
						:html => {:title => "删除", :class => "DeleteComment floatRight tipsyHover"}
					%>
					<% end%>
					<a href="#" class="CommenterImage">
						<img src="/images/avatar/noAvatar.jpg">
					</a>
					<p class="CommenterMeta">
						<a href="#" class="CommenterName"><%= comment.try(:user).try(:name)%></a>说：
						<br />
						<%= comment.content%>
					</p>
				</div>
				<% end%>
			</div>
			<div id="PinAddComment">
				<div id="PinInputArea">
					<% if logged_in?%>
					<%= hidden_field_tag "user_id", current_user.id%>
					<img class="CommenterImage" alt="李" src="/images/avatar/noAvatar.jpg">
					<div class="InputContainer">
						<textarea id="CloseupComment" placeholder="添加评论..." maxlength="1000" name="caption"></textarea>
					</div>
					<div id="PinAddCommentControls">
						<button id="PostComment" class="Button WhiteButton Button13 disabled">添加评论</button>
					</div>
					<% else%>
						请<%= link_to "<font color='red'>登录</font>", {:controller => :user, :action => :login}%>后发表评论，没有帐号？马上<%= link_to "<font color='red'>注册</font>", {:controller => :user, :action => :signup}%>一个 
					<% end%>
				</div>
			</div>
		</div>
	</div>
</div>